import { createApp } from 'vue'
import './style.scss'
import App from './App.vue'
import router from '@/router'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { i18n } from '@/lang/index.js'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// 全局图片替换
import { checkFileUrl } from '@/utils/index.js'

// 自定义指令
import { setupDirective } from '@/directives/index.js'
import VueDOMPurifyHTML from 'vue-dompurify-html'

// 插件
import legacy from './plugins/legacy'
legacy()

const app = createApp(App)
app.config.globalProperties.checkFileUrl = checkFileUrl
// 注册指令(directive)
setupDirective(app)
app.use(VueDOMPurifyHTML)
app.use(router)
app.use(i18n)
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(pinia)
app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.mount('#app')
